home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / misc / 39 / end.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-07-17  |  17.6 KB  |  715 lines

  1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  2. /* end.c - version 1.0.3 */
  3.  
  4. #include <stdio.h>
  5. #ifdef UNIX
  6. #include <signal.h>
  7. #endif UNIX
  8. #include "hack.h"
  9. #define    Sprintf    (void) sprintf
  10. extern char plname[], pl_character[];
  11. extern char *itoa(), *ordin(), *eos();
  12. extern boolean female;            /* should have been flags.female */
  13. xchar maxdlevel = 1;
  14.  
  15. done1()
  16. {
  17. #ifdef UNIX
  18.     (void) signal(SIGINT,SIG_IGN);
  19. #endif UNIX
  20.     pline("Really quit?");
  21.     if(readchar() != 'y') {
  22. #ifdef UNIX
  23.         (void) signal(SIGINT,done1);
  24. #endif UNIX
  25.         clrlin();
  26.         (void) fflush(stdout);
  27.         if(multi > 0) nomul(0);
  28.         return(0);
  29.     }
  30.     done("quit");
  31.     /* NOTREACHED */
  32. }
  33.  
  34. int done_stopprint;
  35. int done_hup;
  36.  
  37. done_intr(){
  38.     done_stopprint++;
  39. #ifdef UNIX
  40.     (void) signal(SIGINT, SIG_IGN);
  41. #ifdef SIGQUIT
  42.     (void) signal(SIGQUIT, SIG_IGN);
  43. #endif
  44. #endif UNIX
  45. }
  46.  
  47. done_hangup(){
  48.     done_hup++;
  49. #ifdef SIGHUP
  50.     (void) signal(SIGHUP, SIG_IGN);
  51. #endif
  52.     done_intr();
  53. }
  54.  
  55. done_in_by(mtmp) register struct monst *mtmp; {
  56. static char buf[BUFSZ];
  57.     pline("You die ...");
  58.     if(mtmp->data->mlet == ' '){
  59.         Sprintf(buf, "the ghost of %s", (char *) mtmp->mextra);
  60.         killer = buf;
  61.     } else if(mtmp->mnamelth) {
  62.         Sprintf(buf, "%s called %s",
  63.             mtmp->data->mname, NAME(mtmp));
  64.         killer = buf;
  65.     } else if(mtmp->minvis) {
  66.         Sprintf(buf, "invisible %s", mtmp->data->mname);
  67.         killer = buf;
  68.     } else killer = mtmp->data->mname;
  69.     done("died");
  70. }
  71.  
  72. /* called with arg "died", "drowned", "escaped", "quit", "choked", "panicked",
  73.    "burned", "starved" or "tricked" */
  74. /* Be careful not to call panic from here! */
  75. done(st1)
  76. register char *st1;
  77. {
  78.  
  79. #ifdef WIZARD
  80.     if(wizard && *st1 == 'd'){
  81.         u.uswldtim = 0;
  82.         if(u.uhpmax < 0) u.uhpmax = 100;    /* arbitrary */
  83.         u.uhp = u.uhpmax;
  84.         pline("For some reason you are still alive.");
  85.         flags.move = 0;
  86.         if(multi > 0) multi = 0; else multi = -1;
  87.         flags.botl = 1;
  88.         return;
  89.     }
  90. #endif WIZARD
  91. #ifdef UNIX
  92.     (void) signal(SIGINT, done_intr);
  93. #ifdef SIGQUIT
  94.     (void) signal(SIGQUIT, done_intr);
  95. #endif
  96. #ifdef SIGHUP
  97.     (void) signal(SIGHUP, done_hangup);
  98. #endif
  99. #endif UNIX
  100.     if(*st1 == 'q' && u.uhp < 1){
  101.         st1 = "died";
  102.         killer = "quit while already on Charon's boat";
  103.     }
  104.     if(*st1 == 's') killer = "starvation"; else
  105.     if(*st1 == 'd' && st1[1] == 'r') killer = "drowning"; else
  106.     if(*st1 == 'p') killer = "panic"; else
  107.     if(*st1 == 't') killer = "trickery"; else
  108.     if(!index("bcd", *st1)) killer = st1;
  109.     paybill();
  110.     clearlocks();
  111.     if(flags.toplin == 1) more();
  112.     if(index("bcds", *st1)){
  113. #ifdef WIZARD
  114.         if(!wizard)
  115. #endif WIZARD
  116.         savebones();
  117.         if(!flags.notombstone)
  118.             outrip();
  119.     }
  120.     if(*st1 == 'c') killer = st1;        /* after outrip() */
  121.     settty((char *) 0);    /* does a clear_screen() */
  122.     if(!done_stopprint)
  123.         printf("Goodbye %s %s...\n\n", pl_character, plname);
  124.     { long int tmp;
  125.       tmp = u.ugold - u.ugold0;
  126.       if(tmp < 0)
  127.         tmp = 0;
  128.       if(*st1 == 'd' || *st1 == 'b')
  129.         tmp -= tmp/10;
  130.       u.urexp += tmp;
  131.       u.urexp += 50 * maxdlevel;
  132.       if(maxdlevel > 20)
  133.         u.urexp += 1000*((maxdlevel > 30) ? 10 : maxdlevel - 20);
  134.     }
  135.     if(*st1 == 'e') {
  136.         extern struct monst *mydogs;
  137.         register struct monst *mtmp;
  138.         register struct obj *otmp;
  139. #ifdef DGK
  140.         long i;
  141. #else
  142.         register int i;
  143. #endif DGK
  144.         register unsigned worthlessct = 0;
  145.         boolean has_amulet = FALSE;
  146.  
  147.         killer = st1;
  148.         keepdogs();
  149.         mtmp = mydogs;
  150.         if(mtmp) {
  151.             if(!done_stopprint) printf("You");
  152.             while(mtmp) {
  153.                 if(!done_stopprint)
  154.                     printf(" and %s", mon_nam(mtmp));
  155.                 if(mtmp->mtame)
  156.                     u.urexp += mtmp->mhp;
  157.                 mtmp = mtmp->nmon;
  158.             }
  159.             if(!done_stopprint)
  160.             printf("\nescaped from the dungeon with %ld points,\n",
  161.             u.urexp);
  162.         } else
  163.         if(!done_stopprint)
  164.           printf("You escaped from the dungeon with %ld points,\n",
  165.             u.urexp);
  166.         for(otmp = invent; otmp; otmp = otmp->nobj) {
  167.             if(otmp->olet == GEM_SYM){
  168.                 objects[otmp->otyp].oc_name_known = 1;
  169. #ifdef DGK
  170.                 i = (long) otmp->quan *
  171.                     objects[otmp->otyp].g_val;
  172. #else
  173.                 i = otmp->quan*objects[otmp->otyp].g_val;
  174. #endif DGK
  175.                 if(i == 0) {
  176.                     worthlessct += otmp->quan;
  177.                     continue;
  178.                 }
  179.                 u.urexp += i;
  180.                 if(!done_stopprint)
  181. #ifdef DGK
  182.                   printf("\t%s (worth %ld Zorkmids),\n",
  183. #else
  184.                   printf("\t%s (worth %d Zorkmids),\n",
  185. #endif DGK
  186.                     doname(otmp), i);
  187.             } else if(otmp->olet == AMULET_SYM) {
  188.                 otmp->known = 1;
  189.                 i = (otmp->spe < 0) ? 2 : 5000;
  190.                 u.urexp += i;
  191.                 if(!done_stopprint)
  192.                   printf("\t%s (worth %d Zorkmids),\n",
  193.                     doname(otmp), i);
  194.                 if(otmp->spe >= 0) {
  195.                     has_amulet = TRUE;
  196.                     killer = "escaped (with amulet)";
  197.                 }
  198.             }
  199.         }
  200.         if(worthlessct) if(!done_stopprint)
  201.           printf("\t%u worthless piece%s of coloured glass,\n",
  202.           worthlessct, plur(worthlessct));
  203.         if(has_amulet) u.urexp *= 2;
  204.     } else
  205.         if(!done_stopprint)
  206.           printf("You %s on dungeon level %d with %ld points,\n",
  207.             st1, dlevel, u.urexp);
  208.     if(!done_stopprint)
  209.       printf("and %ld piece%s of gold, after %ld move%s.\n",
  210.         u.ugold, plur(u.ugold), moves, plur(moves));
  211.     if(!done_stopprint)
  212.   printf("You were level %u with a maximum of %d hit points when you %s.\n",
  213.         u.ulevel, u.uhpmax, st1);
  214.     if(*st1 == 'e' && !done_stopprint){
  215.         getret();    /* all those pieces of coloured glass ... */
  216.         cls();
  217.     }
  218. #ifdef WIZARD
  219.     if(!wizard)
  220. #endif WIZARD
  221.         topten();
  222.     if(done_stopprint) printf("\n\n");
  223.     exit(0);
  224. }
  225.  
  226. #define newttentry() (struct toptenentry *) alloc(sizeof(struct toptenentry))
  227. #define    NAMSZ    10
  228. #define    DTHSZ    40
  229. #define    PERSMAX    1
  230. #define    POINTSMIN    1    /* must be > 0 */
  231. #define    ENTRYMAX    100    /* must be >= 10 */
  232. #ifndef    MSDOS
  233. #define    PERS_IS_UID        /* delete for PERSMAX per name; now per uid */
  234. #endif
  235. struct toptenentry {
  236.     struct toptenentry *tt_next;
  237.     long int points;
  238.     int level,maxlvl,hp,maxhp;
  239.     int uid;
  240.     char plchar;
  241.     char sex;
  242.     char name[NAMSZ+1];
  243.     char death[DTHSZ+1];
  244.     char date[7];        /* yymmdd */
  245. } *tt_head;
  246.  
  247. topten(){
  248.     int uid = getuid();
  249.     int rank, rank0 = -1, rank1 = 0;
  250.     int occ_cnt = PERSMAX;
  251.     register struct toptenentry *t0, *t1, *tprev;
  252.     char *recfile = RECORD;
  253.     char *reclock = "record_lock";
  254.     int sleepct = 300;
  255.     FILE *rfile;
  256.     register flg = 0;
  257.     extern char *getdate();
  258. #define    HUP    if(!done_hup)
  259. #ifndef    MSDOS
  260.     while(link(recfile, reclock) == -1) {
  261.         HUP perror(reclock);
  262.         if(!sleepct--) {
  263.             HUP puts("I give up. Sorry.");
  264.             HUP puts("Perhaps there is an old record_lock around?");
  265.             return;
  266.         }
  267.         HUP printf("Waiting for access to record file. (%d)\n",
  268.             sleepct);
  269.         HUP (void) fflush(stdout);
  270.         sleep(1);
  271.     }
  272. #endif
  273.     if(!(rfile = fopen(recfile,"r"))){
  274.         HUP puts("Cannot open record file!");
  275.         goto unlock;
  276.     }
  277.     HUP (void) putchar('\n');
  278.  
  279.     /* create a new 'topten' entry */
  280.     t0 = newttentry();
  281.     t0->level = dlevel;
  282.     t0->maxlvl = maxdlevel;
  283.     t0->hp = u.uhp;
  284.     t0->maxhp = u.uhpmax;
  285.     t0->points = u.urexp;
  286.     t0->plchar = pl_character[0];
  287.     t0->sex = (female ? 'F' : 'M');
  288.     t0->uid = uid;
  289.     (void) strncpy(t0->name, plname, NAMSZ);
  290.     (t0->name)[NAMSZ] = 0;
  291.     (void) strncpy(t0->death, killer, DTHSZ);
  292.     (t0->death)[DTHSZ] = 0;
  293.     (void) strcpy(t0->date, getdate());
  294.  
  295.     /* assure minimum number of points */
  296.     if(t0->points < POINTSMIN)
  297.         t0->points = 0;
  298.  
  299.     t1 = tt_head = newttentry();
  300.     tprev = 0;
  301.     /* rank0: -1 undefined, 0 not_on_list, n n_th on list */
  302.     for(rank = 1; ; ) {
  303. #ifdef TOS
  304.       char k1[2],k2[2];
  305.       if(fscanf(rfile, "%6s %d %d %d %d %d %ld %1s%1s %s %s]",
  306.         t1->date, &t1->uid,
  307.         &t1->level, &t1->maxlvl,
  308.         &t1->hp, &t1->maxhp, &t1->points,
  309.         k1, k2, t1->name, t1->death) != 11
  310. #else
  311.       if(fscanf(rfile, "%6s %d %d %d %d %d %ld %c%c %[^,],%[^\n]",
  312.         t1->date, &t1->uid,
  313.         &t1->level, &t1->maxlvl,
  314.         &t1->hp, &t1->maxhp, &t1->points,
  315.         &t1->plchar, &t1->sex, t1->name, t1->death) != 11
  316. #endif
  317.       || t1->points < POINTSMIN)
  318.             t1->points = 0;
  319. #ifdef TOS
  320.     t1->plchar=k1[0];
  321.     t1->sex=k2[0];
  322. #endif
  323.       if(rank0 < 0 && t1->points < t0->points) {
  324.         rank0 = rank++;
  325.         if(tprev == 0)
  326.             tt_head = t0;
  327.         else
  328.             tprev->tt_next = t0;
  329.         t0->tt_next = t1;
  330.         occ_cnt--;
  331.         flg++;        /* ask for a rewrite */
  332.       } else
  333.         tprev = t1;
  334.       if(t1->points == 0) break;
  335.       if(
  336. #ifdef PERS_IS_UID
  337.          t1->uid == t0->uid &&
  338. #else
  339.          strncmp(t1->name, t0->name, NAMSZ) == 0 &&
  340. #endif PERS_IS_UID
  341.          t1->plchar == t0->plchar && --occ_cnt <= 0){
  342.         if(rank0 < 0){
  343.             rank0 = 0;
  344.             rank1 = rank;
  345.     HUP printf("You didn't beat your previous score of %ld points.\n\n",
  346.                 t1->points);
  347.         }
  348.         if(occ_cnt < 0){
  349.             flg++;
  350.             continue;
  351.         }
  352.       }
  353.       if(rank <= ENTRYMAX){
  354.           t1 = t1->tt_next = newttentry();
  355.           rank++;
  356.       }
  357.       if(rank > ENTRYMAX){
  358.         t1->points = 0;
  359.         break;
  360.       }
  361.     }
  362.     if(flg) {    /* rewrite record file */
  363.         (void) fclose(rfile);
  364.         if(!(rfile = fopen(recfile,"w"))){
  365.             HUP puts("Cannot write record file\n");
  366.             goto unlock;
  367.         }
  368.  
  369.         if(!done_stopprint) if(rank0 > 0){
  370.             if(rank0 <= 10)
  371.             puts("You made the top ten list!\n");
  372.             else
  373.         printf("You reached the %d%s place on the top %d list.\n\n",
  374.             rank0, ordin(rank0), ENTRYMAX);
  375.         }
  376.     }
  377.     if(rank0 == 0) rank0 = rank1;
  378.     if(rank0 <= 0) rank0 = rank;
  379.     if(!done_stopprint) outheader();
  380.     t1 = tt_head;
  381.     for(rank = 1; t1->points != 0; rank++, t1 = t1->tt_next) {
  382. #ifdef TOS
  383.       if(flg) fprintf(rfile,"%6s %d %d %d %d %d %ld %c%c %s %s\n",
  384. #else
  385.       if(flg) fprintf(rfile,"%6s %d %d %d %d %d %ld %c%c %s,%s\n",
  386. #endif
  387.         t1->date, t1->uid,
  388.         t1->level, t1->maxlvl,
  389.         t1->hp, t1->maxhp, t1->points,
  390.         t1->plchar, t1->sex, t1->name, t1->death);
  391.       if(done_stopprint) continue;
  392.       if(rank > flags.end_top &&
  393.         (rank < rank0-flags.end_around || rank > rank0+flags.end_around)
  394.         && (!flags.end_own ||
  395. #ifdef PERS_IS_UID
  396.                   t1->uid != t0->uid ))
  397. #else
  398.                   strncmp(t1->name, t0->name, NAMSZ)))
  399. #endif PERS_IS_UID
  400.           continue;
  401.       if(rank == rank0-flags.end_around &&
  402.          rank0 > flags.end_top+flags.end_around+1 &&
  403.          !flags.end_own)
  404.         (void) putchar('\n');
  405.       if(rank != rank0)
  406.         (void) outentry(rank, t1, 0);
  407.       else if(!rank1)
  408.         (void) outentry(rank, t1, 1);
  409.       else {
  410.         int t0lth = outentry(0, t0, -1);
  411.         int t1lth = outentry(rank, t1, t0lth);
  412.         if(t1lth > t0lth) t0lth = t1lth;
  413.         (void) outentry(0, t0, t0lth);
  414.       }
  415.     }
  416.     if(rank0 >= rank) if(!done_stopprint)
  417.         (void) outentry(0, t0, 1);
  418.     (void) fclose(rfile);
  419. unlock:
  420.     (void) unlink(reclock);
  421. }
  422.  
  423. outheader() {
  424. char linebuf[BUFSZ];
  425. register char *bp;
  426.     (void) strcpy(linebuf, "Number Points  Name");
  427.     bp = eos(linebuf);
  428.     while(bp < linebuf + COLNO - 9) *bp++ = ' ';
  429.     (void) strcpy(bp, "Hp [max]");
  430.     puts(linebuf);
  431. }
  432.  
  433. /* so>0: standout line; so=0: ordinary line; so<0: no output, return lth */
  434. int
  435. outentry(rank,t1,so) register struct toptenentry *t1; {
  436. boolean quit = FALSE, killed = FALSE, starv = FALSE;
  437. char linebuf[BUFSZ];
  438.     linebuf[0] = 0;
  439.     if(rank) Sprintf(eos(linebuf), "%3d", rank);
  440.         else Sprintf(eos(linebuf), "   ");
  441. #ifdef DGK
  442.     Sprintf(eos(linebuf), " %6ld %10s", t1->points, t1->name);
  443. #else
  444.     Sprintf(eos(linebuf), " %6ld %8s", t1->points, t1->name);
  445. #endif DGK
  446.     if(t1->plchar == 'X') Sprintf(eos(linebuf), " ");
  447.     else Sprintf(eos(linebuf), "-%c ", t1->plchar);
  448.     if(!strncmp("escaped", t1->death, 7)) {
  449.       if(!strcmp(" (with amulet)", t1->death+7))
  450.         Sprintf(eos(linebuf), "escaped the dungeon with amulet");
  451.       else
  452.         Sprintf(eos(linebuf), "escaped the dungeon [max level %d]",
  453.           t1->maxlvl);
  454.     } else {
  455.       if(!strncmp(t1->death,"quit",4)) {
  456.         quit = TRUE;
  457.         if(t1->maxhp < 3*t1->hp && t1->maxlvl < 4)
  458.           Sprintf(eos(linebuf), "cravenly gave up");
  459.         else
  460.         Sprintf(eos(linebuf), "quit");
  461.       }
  462.       else if(!strcmp(t1->death,"choked"))
  463.         Sprintf(eos(linebuf), "choked on %s food",
  464.         (t1->sex == 'F') ? "her" : "his");
  465.       else if(!strncmp(t1->death,"starv",5))
  466.         Sprintf(eos(linebuf), "starved to death"), starv = TRUE;
  467.       else Sprintf(eos(linebuf), "was killed"), killed = TRUE;
  468.       Sprintf(eos(linebuf), " on%s level %d",
  469.         (killed || starv) ? "" : " dungeon", t1->level);
  470.       if(t1->maxlvl != t1->level)
  471.         Sprintf(eos(linebuf), " [max %d]", t1->maxlvl);
  472.       if(quit && t1->death[4]) Sprintf(eos(linebuf), t1->death + 4);
  473.     }
  474.     if(killed) Sprintf(eos(linebuf), " by %s%s",
  475.       (!strncmp(t1->death, "trick", 5) || !strncmp(t1->death, "the ", 4))
  476.         ? "" :
  477.       index(vowels,*t1->death) ? "an " : "a ",
  478.       t1->death);
  479.     Sprintf(eos(linebuf), ".");
  480.     if(t1->maxhp) {
  481.       register char *bp = eos(linebuf);
  482.       char hpbuf[10];
  483.       int hppos;
  484.       Sprintf(hpbuf, (t1->hp > 0) ? itoa(t1->hp) : "-");
  485.       hppos = COLNO - 7 - strlen(hpbuf);
  486.       if(bp <= linebuf + hppos) {
  487.         while(bp < linebuf + hppos) *bp++ = ' ';
  488.         (void) strcpy(bp, hpbuf);
  489.         Sprintf(eos(bp), " [%d]", t1->maxhp);
  490.       }
  491.     }
  492.     if(so == 0) puts(linebuf);
  493.     else if(so > 0) {
  494.       register char *bp = eos(linebuf);
  495.       if(so >= COLNO) so = COLNO-1;
  496.       while(bp < linebuf + so) *bp++ = ' ';
  497.       *bp = 0;
  498.       standoutbeg();
  499.       fputs(linebuf,stdout);
  500.       standoutend();
  501. #ifdef DGK
  502.     /* This is needed to get the screen back to normal after standout */
  503.       end_screen();
  504. #endif DGK
  505.       (void) putchar('\n');
  506.     }
  507.     return(strlen(linebuf));
  508. }
  509.  
  510. char *
  511. itoa(a) int a; {
  512. static char buf[12];
  513.     Sprintf(buf,"%d",a);
  514.     return(buf);
  515. }
  516.  
  517. char *
  518. ordin(n) int n; {
  519. register int d = n%10;
  520.     return((d==0 || d>3 || n/10==1) ? "th" : (d==1) ? "st" :
  521.         (d==2) ? "nd" : "rd");
  522. }
  523.  
  524. clearlocks(){
  525. register x;
  526. #ifdef SIGHUP
  527.     (void) signal(SIGHUP,SIG_IGN);
  528. #endif
  529.     for(x = maxdlevel; x >= 0; x--) {
  530.         glo(x);
  531.         (void) unlink(lock);    /* not all levels need be present */
  532.     }
  533. }
  534.  
  535. #ifdef NOSAVEONHANGUP
  536. hangup()
  537. {
  538.     (void) signal(SIGINT, SIG_IGN);
  539.     clearlocks();
  540.     exit(1);
  541. }
  542. #endif NOSAVEONHANGUP
  543.  
  544. char *
  545. eos(s)
  546. register char *s;
  547. {
  548.     while(*s) s++;
  549.     return(s);
  550. }
  551.  
  552. /* it is the callers responsibility to check that there is room for c */
  553. charcat(s,c) register char *s, c; {
  554.     while(*s) s++;
  555.     *s++ = c;
  556.     *s = 0;
  557. }
  558.  
  559. /*
  560.  * Called with args from main if argc >= 0. In this case, list scores as
  561.  * requested. Otherwise, find scores for the current player (and list them
  562.  * if argc == -1).
  563.  */
  564. prscore(argc,argv) int argc; char **argv; {
  565.     extern char *hname;
  566.     char **players;
  567.     int playerct;
  568.     int rank;
  569.     register struct toptenentry *t1, *t2;
  570.     char *recfile = RECORD;
  571.     FILE *rfile;
  572.     register flg = 0;
  573.     register int i;
  574. #ifdef nonsense
  575.     long total_score = 0L;
  576.     char totchars[10];
  577.     int totcharct = 0;
  578. #endif nonsense
  579.     int outflg = (argc >= -1);
  580. #ifdef PERS_IS_UID
  581.     int uid = -1;
  582. #else
  583.     char *player0;
  584. #endif PERS_IS_UID
  585.  
  586.     if(!(rfile = fopen(recfile,"r"))){
  587.         puts("Cannot open record file!");
  588.         return;
  589.     }
  590.  
  591.     if(argc > 1 && !strncmp(argv[1], "-s", 2)){
  592.         if(!argv[1][2]){
  593.             argc--;
  594.             argv++;
  595.         } else if(!argv[1][3] && index("CFKSTWX", argv[1][2])) {
  596.             argv[1]++;
  597.             argv[1][0] = '-';
  598.         } else    argv[1] += 2;
  599.     }
  600.     if(argc <= 1){
  601. #ifdef PERS_IS_UID
  602.         uid = getuid();
  603.         playerct = 0;
  604. #else
  605.         player0 = plname;
  606.         if(!*player0)
  607.             player0 = "hackplayer";
  608.         playerct = 1;
  609.         players = &player0;
  610. #endif PERS_IS_UID
  611.     } else {
  612.         playerct = --argc;
  613.         players = ++argv;
  614.     }
  615.     if(outflg) putchar('\n');
  616.  
  617.     t1 = tt_head = newttentry();
  618.     for(rank = 1; ; rank++) {
  619. #ifdef TOS
  620.     char k1[2],k2[2];
  621.       if(fscanf(rfile, "%6s %d %d %d %d %d %ld %1s%1s %s %s]",
  622.         t1->date, &t1->uid,
  623.         &t1->level, &t1->maxlvl,
  624.         &t1->hp, &t1->maxhp, &t1->points,
  625.         k1, k2, t1->name, t1->death) != 11)
  626. #else TOS
  627.       if(fscanf(rfile, "%6s %d %d %d %d %d %ld %c%c %[^,],%[^\n]",
  628.         t1->date, &t1->uid,
  629.         &t1->level, &t1->maxlvl,
  630.         &t1->hp, &t1->maxhp, &t1->points,
  631.         &t1->plchar, &t1->sex, t1->name, t1->death) != 11)
  632. #endif
  633.             t1->points = 0;
  634. #ifdef TOS
  635.       t1->plchar=k1[0];
  636.       t1->sex=k2[0];
  637. #endif
  638.       if(t1->points == 0) break;
  639. #ifdef PERS_IS_UID
  640.       if(!playerct && t1->uid == uid)
  641.         flg++;
  642.       else
  643. #endif PERS_IS_UID
  644.       for(i = 0; i < playerct; i++){
  645.         if(strcmp(players[i], "all") == 0 ||
  646.            strncmp(t1->name, players[i], NAMSZ) == 0 ||
  647.           (players[i][0] == '-' &&
  648.            players[i][1] == t1->plchar &&
  649.            players[i][2] == 0) ||
  650.           (digit(players[i][0]) && rank <= atoi(players[i])))
  651.             flg++;
  652.       }
  653.       t1 = t1->tt_next = newttentry();
  654.     }
  655.     (void) fclose(rfile);
  656.     if(!flg) {
  657.         if(outflg) {
  658.         printf("Cannot find any entries for ");
  659.         if(playerct < 1) printf("you.\n");
  660.         else {
  661.           if(playerct > 1) printf("any of ");
  662.           for(i=0; i<playerct; i++)
  663.             printf("%s%s", players[i], (i<playerct-1)?", ":".\n");
  664.           printf("Call is: %s -s [playernames]\n", hname);
  665.         }
  666.         }
  667.         return;
  668.     }
  669.  
  670.     if(outflg) outheader();
  671.     t1 = tt_head;
  672.     for(rank = 1; t1->points != 0; rank++, t1 = t2) {
  673.         t2 = t1->tt_next;
  674. #ifdef PERS_IS_UID
  675.         if(!playerct && t1->uid == uid)
  676.             goto outwithit;
  677.         else
  678. #endif PERS_IS_UID
  679.         for(i = 0; i < playerct; i++){
  680.             if(strcmp(players[i], "all") == 0 ||
  681.                strncmp(t1->name, players[i], NAMSZ) == 0 ||
  682.               (players[i][0] == '-' &&
  683.                players[i][1] == t1->plchar &&
  684.                players[i][2] == 0) ||
  685.               (digit(players[i][0]) && rank <= atoi(players[i]))){
  686.             outwithit:
  687.                 if(outflg)
  688.                     (void) outentry(rank, t1, 0);
  689. #ifdef nonsense
  690.                 total_score += t1->points;
  691.                 if(totcharct < sizeof(totchars)-1)
  692.                     totchars[totcharct++] = t1->plchar;
  693. #endif nonsense
  694.                 break;
  695.             }
  696.         }
  697.         free((char *) t1);
  698.     }
  699. #ifdef nonsense
  700.     totchars[totcharct] = 0;
  701.  
  702.     /* We would like to determine whether he is experienced. However,
  703.        the information collected here only tells about the scores/roles
  704.        that got into the topten (top 100?). We should maintain a
  705.        .hacklog or something in his home directory. */
  706.     flags.beginner = (total_score < 6000);
  707.     for(i=0; i<6; i++)
  708.         if(!index(totchars, "CFKSTWX"[i])) {
  709.         flags.beginner = 1;
  710.         if(!pl_character[0]) pl_character[0] = "CFKSTWX"[i];
  711.         break;
  712.     }
  713. #endif nonsense
  714. }
  715.